package com.infocollect.project.api.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.infocollect.project.api.entity.TappDeptEntity;
import com.infocollect.project.api.mapper.TappDeptMapper;
import com.infocollect.project.api.service.ITappDeptService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (TappDept)表服务实现类
 *
 * @author makejava
 * @since 2019-12-25 10:32:28
 */
@Service("tappDeptService")
public class TappDeptServiceImpl extends ServiceImpl<TappDeptMapper, TappDeptEntity> implements ITappDeptService {


    /**
     * 通过ID查询单条数据
     *
     * @param fid 主键
     * @return 实例对象
     */
    @Override
    public TappDeptEntity queryById(Long fid) {
        return this.baseMapper.selectById(fid);
   }


    /**
     * 查询多条数据
     * @menu 根据实体对象是否有值 进行查询
     * @return 对象列表
     */
    @Override
    public List<TappDeptEntity> queryAll(TappDeptEntity dept){
        return this.baseMapper.queryAll(dept);
    }
    /**
     * 新增数据
     *
     * @param tappDept 实例对象
     * @return 实例对象
     */
    @Override
    public TappDeptEntity insert(TappDeptEntity tappDept) {
        this.baseMapper.insert(tappDept);
        return tappDept;
    }

    /**
     * 修改数据
     *
     * @param tappDept 实例对象
     * @return 实例对象
     */
    @Override
    public TappDeptEntity update(TappDeptEntity tappDept) {
        this.baseMapper.updateById(tappDept);
        return this.queryById(tappDept.getFid());
    }

    /**
     * 通过主键删除数据
     *
     * @param fid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long fid) {
        return this.baseMapper.deleteById(fid) > 0;
    }

    /**
     *
     * @param fdeptcode
     * @return
     */
    @Override
    public  TappDeptEntity queryByCode(String fdeptcode){

        return this.baseMapper.queryByCode(fdeptcode);
    }

    /**
     *
     * @param fparentid
     * @return
     */
    @Override
    public  List<TappDeptEntity> queryByParentID(Long fparentid){
        return this.baseMapper.queryByParentID(fparentid);

    }
    /**
     * 根据部门名称和code查询
     * @param workkey
     * @return
     */
    public List<TappDeptEntity> queryNameOrCode(String workkey){
        return this.baseMapper.queryNameOrCode(workkey);
    }
}